'use strict'



class zanguo{
    constructor(){
        this.param = '/'
    }


    async get(c){
        let a = c.service.fun;
        let {user_id} = c.query;
        //let data1 = await a.sel('user_list',{'user_id':`${user_id}`},['user_head','user_name'],c.service.pool);
        let data1 = await a.sel('like_list',{'like_user_id':`${user_id}`},['liked_user_id','liked_article_id'],c.service.pool);
        console.log(data1.rows);
        let data2 = [];
        for (var i=0;i<data1.rows.length;i++){
            let aa = await a.sel('article_list',{'article_id':`${data1.rows[i].liked_article_id}`},['article_id','article_title','article_txt','article_img','article_time','article_place'],c.service.pool)
            console.log(aa.rows);
            
            let  bb = await a.sel('user_list',{'user_id':`${data1.rows[i].liked_user_id}`},['user_name','user_head'],c.service.pool);
            console.log(bb.rows);
            let {article_id,article_title,article_txt,article_img,article_time,article_place}=aa.rows[0];
            let {user_name,user_head} = bb.rows[0];
            console.log(article_id)
            data2.push({article_id,article_title,article_txt,article_img,article_time,article_place,user_name,user_head});
        }

        c.send({
            type:'array',
            data:data2
        }) 

        //let data3 = await a.sel('like_list',{'like_user_id':`${user_id}`,['liked_artile_id'],c.service.pool);
    }
}


module.exports = zanguo
